package com.itheima.reggie.mapper;

import com.itheima.reggie.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    @Options(useGeneratedKeys = true, keyProperty = "id")
//在插入数据时会将数据库表中自增字段id自动生成的值赋给Service层调用此insert方法时传递的user对象中的成员变量id,从而在Service层中可以获得自动生成的id字段
    @Insert("insert into user values (#{id},#{name},#{phone},#{sex},#{idNumber},#{avatar},#{status})")
    void insert(User user);

    @Select("select * from user where phone = #{phone}")
    User selectByPhone(String phone);
}
